﻿///////////////////////////////////////////////////////////////////////////////
//
// This file is part of the BassDrop project
//   https://code.google.com/p/bass-drop/
//
//
// Creator:	Gergely Krajcsovszki (krajcsovszkig@hotmail.com)
// Date:	2014-05-02 20:20
//
//
// Copyright © 2013-2014. Gergely Krajcsovszki
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
///////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Media;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using BassDrop.DesktopClient.Utilities;

namespace BassDrop.DesktopClient.UI.Dialogs
{
	/// <summary>
	/// Interaction logic for InputDialog.xaml
	/// </summary>
	public partial class InputDialog : Window
	{
		protected InputDialog( string caption, string description )
		{
			InitializeComponent();

			TextBlockMessage.Text = description;
			Title = caption;

			ImageDialogIcon.Source = SystemIcons.Question.ToImageSource();

			TextBoxAnswer.Focus();
		}

		/// <summary>
		/// Show a new text input dialog to read in a string from the user
		/// </summary>
		/// <param name="owner">The owner window of the dialog</param>
		/// <param name="messageBoxText">The description on the dialog</param>
		/// <param name="caption">The title of the dialog window</param>
		/// <param name="result">Output parameter to get the string entered by the user</param>
		/// <returns>True if the user clicked OK, false if they clicked Cancel</returns>
		public static bool? ShowDialog( Window owner, string messageBoxText, string caption, out string result )
		{
			var window = new InputDialog( caption, messageBoxText );
			window.Owner = owner;

			SystemSounds.Question.Play();

			var rvalue = window.ShowDialog();
			result = window.TextBoxAnswer.Text;

			return rvalue;
		}

		private void ButtonOK_Click( object sender, RoutedEventArgs e )
		{
			DialogResult = true;
		}
	}
}
